// package-market/pages/lottery-record/index.js
import { UserInfoUpdateMixins, PageScrollListMixins, OriginEnsureToOrderReviewMixins, RedeemPrizeToOrderReviewMixins } from '../../../behaviors/page';
import { showLoading, hideLoading } from '../../../common/env';
import { getAwawrdList } from '../../api/lottery';
let activityId;

Page({
    mixins: [UserInfoUpdateMixins, PageScrollListMixins, OriginEnsureToOrderReviewMixins, RedeemPrizeToOrderReviewMixins],
    data: {
        originId: '',
        originInfo: {},
    },
    onLoad(options) {
        activityId = options.activityId;
    },
    async _handleGetList(pageNo) {
        !this.data.loaded && showLoading('加载中...');
        const { pageData } = this.data;
        let { ts } = pageData;
        pageNo === 1 && (ts = Date.now());
        const { rows = [], total } = await getAwawrdList({ activityId, pageNo, ts });
        this.setData({
            pageData: {
                ...pageData,
                refresh: false,
                ts,
                pageNo,
                total,
                rows: pageNo == 1 ? rows : [...pageData.rows, ...rows],
            },
        });
        if (!this.data.loaded) hideLoading(); this.setData({ loaded: true });
    },
})
